package com.xnyzc.lhy.order.controller.capi.order;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.order.IOaOrderCorrelationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 乘客端订单相关 前端控制器
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-18
 */
@RestController
@RequestMapping(value = "/capi/order")
public class OrderCorrelationController {

    @Autowired
    private IOaOrderCorrelationService orderCorrelationService;

    @ApiOperation("获取订单列表")
    @GetMapping(value = "/getUserOrderList")
    public Rv getUserOrderList(
            @RequestParam(value = "type") String type,
            @RequestParam(value = "page") Integer page) {
        Long userId = TokenUtil.getTokenUserId();
        return orderCorrelationService.getUserOrderList(type,page,userId);
    }

    @ApiOperation("获取行程结束详情")
    @GetMapping("/getUserOrderTrip")
    public Rv getUserOrderTrip(
            @RequestParam(value = "orderNo") String orderNo
    ) {
        return orderCorrelationService.getUserOrderTrip(orderNo);
    }

    @ApiOperation("获取支付详情")
    @GetMapping("/getPayOrderDetails")
    public Rv getPayOrderDetails(
            @RequestParam(value = "orderNo") String orderNo
    ) {
        Long userId = TokenUtil.getTokenUserId();
        return orderCorrelationService.getPayOrderDetails(orderNo,userId);
    }

    @ApiOperation("取消订单")
    @GetMapping("/getCancelOrder")
    public Rv getCancelOrder(
            @RequestParam(value = "orderNo") String orderNo
    ) {
        Long userId = TokenUtil.getTokenUserId();
        return orderCorrelationService.getCancelOrder(orderNo,userId);
    }

    @ApiOperation("费用详情")
    @GetMapping("/getOrderCostDetail")
    public Rv getOrderCostDetail(
            @RequestParam(value = "orderNo") String orderNo
    ) {
        Long userId = TokenUtil.getTokenUserId();
        return orderCorrelationService.getOrderCostDetail(orderNo,userId);
    }
}
